package List_;

import java.awt.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Company {
    private String cname;
    private String adress;
    private String scope;
    private String number;
    int count = 0;
    List<Employee> list = new ArrayList<>();

    public Company() {
    }

    public Company(String cname, String adress, String scope, String number) {
        this.cname = cname;
        this.adress = adress;
        this.scope = scope;
        this.number = number;
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }

    public String getAdress() {
        return adress;
    }

    public void setAdress(String adress) {
        this.adress = adress;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public void showCompany() {
        System.out.println("公司名称" + cname);
        System.out.println("公司地址" + adress);
        System.out.println("公司电话号码" + number);
        System.out.println("公司经营范围" + scope);
    }

    //输出员工信息
    public void showstaff() {
        System.out.println("显示员工信息");
        System.out.println("序号\t姓名\t年龄\t性别\t职务\t薪水");
        for (int i = 0; i < count; i++) {
            System.out.println((i + 1) + " " + list.get(i).getName() + " " + list.get(i).getAge() + " " + list.get(i).getSex() + " " + list.get(i).getPost() + " " + list.get(i).getSalary());
        }
    }

    //添加员工
    public boolean add(String name, int age, String sex, String post, double salary) {
        for (Employee employee : list) {
            if (employee.getName().equals(name)) {
                return false;
            }
        }
        list.add(new Employee(name, age, sex, post, salary));
        return true;
    }

    //辞退员工
    public boolean fire(String name) {
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getName().equals(name)) {
                list.remove(i);
                return true;
            }
        }
        return false;
    }

    //显示公司人数
    public void shows() {
        System.out.println(list.size());
    }

    //获得公司薪水最高的员工的方法
    String name1;

    public void findTopSalary() {

        double max = 0;
        for (int i = 0; i < list.size(); i++) {
            if (max < list.get(i).getSalary()) {
                max = list.get(i).getSalary();
                name1 = list.get(i).getName();
            }
        }
        System.out.println("薪水最高的人是：" + name1 + "工资为" + max);

    }
}
